document.write("<script language=javascript src='/static/crypto-js-4.1.1/crypto-js.js'></script>");

function IsEmpty(value) {
    // 判断字符串是否为空
    if (typeof value == "undefined" || value == null || value == "") {
        return true;
    } else {
        return false;
    }
}


function JudgeUsername(str_to_match) {
    return /[a-zA-Z_0-9\u4e00-\u9fa5]+/.test(str_to_match);
}


function JudgePassWord(str_to_match) {
    // 要确保密码符合要求, 必须要包含字母大小写, 数字, 下划线, 特殊字符, 不得包含汉字
    // 匹配是否含有特殊字符, 是否含有大小写字母, 数字
    res_1 = /\w+|\ |\【|\】|\（|\）|\，|\。|\？|\、|\；|\：|\‘|\’|\“|\”|\！|\《|\》|\￥|\……|\——|\/|\~|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/.test(str_to_match);

    // 匹配是否有汉字
    res_3 = /[\u4e00-\u9fa5]/.test(str_to_match);

    if (res_1 && !res_3) {
        // 密码长度要在: 8~16 范围内
        if (str_to_match.length >= 8 && str_to_match.length <= 16) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}


function JudgeEMail(str_to_match) {
    return /^[A-Za-z0-9_\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(str_to_match);
}


function JudgePhoneNum(str_to_match) {
    return /^1[1-9]\d{9}$/.test(str_to_match);
}


function aesEncrypt(str_encryption) {
    let aesPrivateKey = "112233ynysj18306";
    var key = CryptoJS.enc.Utf8.parse(aesPrivateKey);
    var srcs = CryptoJS.enc.Utf8.parse(str_encryption);
    var encrypted = CryptoJS.AES.encrypt(srcs, key, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}


function StringFormat() 
{
         if (arguments.length == 0)
             return null;
         var str = arguments[0];
         for (var i = 1; i < arguments.length; i++) 
         {
             var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
             str = str.replace(re, arguments[i]);
         }
         return str;
} 


function getNowFormatDate() {
    var date = new Date();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();

    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }

    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }

    var currentdate = date.getFullYear() + "-" + month + "-" + strDate
            + "T" + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
            
    return currentdate;
}